Repository navigation
perf(scheduler): skip NodeLocalGreedy nodes that cannot host a pending task - #2829
Open
sam-huang1223 wants to merge 1 commit into
Open
sam-huang1223 wants to merge 1 commit into
sam-huang1223 wants to merge 1 commit into
Conversation
…g task NodeLocalGreedy simulated a scenario for every node of the latest victim, even when evicting that node's victims could not free room for any pending task. MultiNodeGang's sub-scenario emitter already drops such nodes: a node whose capacity after eviction is below the smallest pending task's GPU request cannot host any pending task. Apply the same rule in nodeLocalScenarios. NodeLocalCapacity computes the capacity nodeCapacities does, keeping a running per-node sum of the accumulated victims' GPUs, and shares its predicate with sortViableCandidates. Fixes kai-scheduler#2826 Signed-off-by: Sam Huang <19882250+sam-huang1223@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 4 tasks
enoodle
reviewed
Dec 6, 2026
Collaborator
There was a problem hiding this comment.
its a performance improvement, it doesn't need changelog imo
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
NodeLocalGreedysimulated a scenario for every node of the latest victim, even when evicting that node's victims could not free room for any pending task.MultiNodeGang's sub-scenario emitter already drops such nodes: a node whose capacity after eviction is below the smallest pending task's GPU request cannot host any pending task. That capacity is the node's idle and releasing GPUs, plus the GPUs of the recorded and potential victims on it.This applies the same rule in
nodeLocalScenarios.NodeLocalCapacitycomputes the capacitynodeCapacitiescomputes, from the same parts (recordedFreedByNode,nodeIdleOrReleasingGpus,pendingTaskGpuStats). It keeps a running per-node sum of the accumulated victims' GPUs, because accumulation only appends victims, so a check costs a map lookup and the generator doesn't rebuild batches at every step.canHostSmallestPendingTaskis the predicate thatsortViableCandidatesandNodeLocalCapacitynow share, so the two generators keep one rule. Pending tasks that request no GPUs still fit every node, as before.A skipped scenario cannot free room for a pending task on its node. On main its simulation could still succeed only by placing the job on other room, which means the job fit without those evictions; allocate places such jobs before reclaim, preempt and consolidation run. Like the emitter, the check counts only a node's own share of a victim batch that spans nodes. Such a batch frees room on its other nodes too, but each of those nodes gets its own scenario when the batch is added, and its own share counts there.
Related Issues
Fixes #2826
Checklist
make changelog(or applied theskip-changeloglabel). Do not editCHANGELOG.mddirectly — pending fragments are folded into it at release time.Breaking Changes
None.
Additional Notes
TestNodeLocalGreedySkipsNodesThatCannotHostAPendingTaskTestNodeLocalGreedyCountsTheNodesFreeGPUsTestNodeLocalGreedyCountsRecordedVictimsOnTheNodeTestNodeLocalGreedyCountsOnlyTheNodesShareOfAVictimBatchTestNodeLocalGreedyKeepsEveryNodeForPendingTasksWithoutGPUsTestNodeLocalCapacityMatchesTheEmitterRuleNodeLocalCapacityagrees withnodeCapacitiesandsortViableCandidateson every node that holds a victim, and both answers occur.TestReclaimSkipsNodesThatCannotHostAPendingTaskNodeCapacitylayout of the unschedulable distributed job benchmark: an elastic victim job with one GPU on each of 50 nodes, beside the reclaimer queue's own GPUs, plus a node with idle GPUs and no free CPU. 51 scenarios are simulated without the change and 1 with it, MultiNodeGang's empty sub-scenario. No eviction either way.reclaim_node_capacity_test.goNodeLocalGreedyscenario and evicts nothing. Fails without the change.Mutants of
CanHostPendingTaskthat ignore recorded victims, ignore idle and releasing GPUs, count a victim on every node, or always answer yes are each caught by at least two of these tests.Benchmarks: same base commit, with and without the change, runs interleaved, benchstat:
ReclaimUnschedulableDistributedJob_NodeCapacity100Node(new layout), sec/opReclaimUnschedulableDistributedJob_100Node, sec/opNo significant change in sec/op for the other
ReclaimUnschedulableDistributedJob_*layouts,ReclaimLargeJobs_*,ReclaimManySingleGPUJobsFullCycle_*, or the reclaim, preempt, consolidation and full-cycle action benchmarks (n=6, re-checked with n=10 where p<0.05 at n=6). Allocations rise by at most 0.4%, exceptConsolidationAction_SmallCluster(+2.1% allocs, time unchanged). That benchmark runs consolidation without allocate, so some pending jobs fit without any eviction, and main simulated, and accepted, scenarios that evict needlessly on nodes this check skips. Profiling attributes under 0.2% of its allocations to the check itself. With allocate first, as in a scheduling cycle, decisions are unchanged.Ran:
go build ./...,go test ./pkg/scheduler/...(all packages pass) andmake validate(golangci-lint, 0 issues). The e2e spec passes on a local kind cluster set up withhack/setup-e2e-cluster.sh --local-images-build(two GPU workers), and fails there against a scheduler built frommain.#2811 and #2812 also change
nodeLocalScenarios, so whichever merges second needs a small rebase. The changes compose: #2812 builds fewer scenarios, and this simulates fewer of them.#2830 adds a similar e2e spec with its own helpers in the same package; whichever merges second can switch to the other's helpers.
🤖 Generated with Claude Code